//
//  AppDelegate.swift
//  XLWibo-Swift
//
//  Created by 王林 on 2016/11/12.
//  Copyright © 2016年 木木. All rights reserved.
//

import UIKit
import CoreData



@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    
    var window: UIWindow?
    

    
    
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        window = UIWindow(frame: UIScreen.main.bounds)

        //注册通知
        changeVC()
        
        window?.backgroundColor = UIColor.white
        window?.rootViewController = WBUserAccessViewModel.shared.userLogin ? WBWelcomeViewController() : WBTarBarController()

        
        window?.makeKeyAndVisible()
        return true
    }
    
    //接受通知
    func changeVC(){
        NotificationCenter.default.addObserver(self, selector: #selector(getNotifation(noti:)), name: NSNotification.Name(KChangeRootViewController), object: nil)
    }
    
    func getNotifation(noti:Notification){
        let VC = (noti.object == nil ? WBTarBarController() : WBWelcomeViewController() )
        
        window?.rootViewController = VC
    }
    
}

